﻿using Data.Service.Service;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Data.Service
{
    //自动橱窗
    public class Intelligence_AutoWindowData
    {
        public static SYTDataBaseEntities db = new SYTDataBaseEntities();
        //获取橱窗设置
        public static Intelligence_AutoWindow GetAutoWindow(string memberId)
        {
            Intelligence_AutoWindow autoWindow = db.Intelligence_AutoWindow.Where(M => M.MemberId == memberId).FirstOrDefault();

            if (autoWindow != null)
            {
                return autoWindow;
            }
            else
            {
                Intelligence_AutoWindow newAutoWindow = new Intelligence_AutoWindow();
                newAutoWindow.IsAutoWindow = false;
                newAutoWindow.IsAllProduct = true;
                newAutoWindow.MemberId = memberId;
                newAutoWindow.CreateTime = DateTime.Now;
                newAutoWindow.UpdateTime = DateTime.Now;

                AddAutoWindow(newAutoWindow);//添加的数据库
                return newAutoWindow;
            }
        }

        //修改数据
        public static bool UpdateAutoWindow(Intelligence_AutoWindow autoWindow)
        {
            return BaseServer<Intelligence_AutoWindow>.UpdateEntity(autoWindow);
        }

        //添加一条数据
        public static bool AddAutoWindow(Intelligence_AutoWindow autoWindow)
        {
            return BaseServer<Intelligence_AutoWindow>.AddEntity(autoWindow);
        }
    }
}
